<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

<p:dialog id="workflowNodeDialog" widgetVar="workflowNodeWidgetVar" modal="true" header="节点管理"
          resizable="false" width="1200" height="600">

    <p:ajax event="close" update="workflowDefinitionListForm:workflowDataTable"/>

    <div class="clearfix"
         style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
        <p:toolbar id="workflowNodeToolBar">
            <f:facet name="right">
                <p:commandButton value="用户"
                                 icon="fa fa-users"
                                 process="@this"
                                 rendered="#{workflowNodeBean.selectedActivityResponse != null and workflowNodeBean.selectedActivityResponse.userEvent}"
                                 oncomplete="PF('workflowNodeUserWidgetVar').show();" update="workflowNodeUserDialog"/>
                <p:commandButton value="角色"
                                 icon="fa fa-graduation-cap"
                                 process="@this"
                                 rendered="#{workflowNodeBean.selectedActivityResponse != null and workflowNodeBean.selectedActivityResponse.userEvent}"
                                 oncomplete="PF('workflowNodeRoleWidgetVar').show();" update="workflowNodeRoleDialog"/>
                <p:commandButton value="执行者变量"
                                 icon="fa fa-file"
                                 process="@this"
                                 rendered="#{workflowNodeBean.selectedActivityResponse != null and workflowNodeBean.selectedActivityResponse.userEvent}"
                                 oncomplete="PF('workflowNodeVariablesWidgetVar').show();"
                                 update="workflowNodeVariablesDialog"/>
                <p:commandButton value="表单地址"
                                 icon="fa fa-file-text-o"
                                 process="@this"
                                 rendered="#{workflowNodeBean.selectedActivityResponse != null and workflowNodeBean.selectedActivityResponse.userEvent}"
                                 oncomplete="PF('workflowNodeFormWidgetVar').show();" update="workflowNodeFormDialog"/>
                <p:commandButton value="脚本任务"
                                 icon="fa fa-file-text"
                                 process="@this"
                                 actionListener="#{workflowNodeBean.onEditScriptTask}"
                                 update="workflowScriptTaskDialog"
                                 oncomplete="PF('workflowScriptTaskWidgetVar').show()"
                                 rendered="#{workflowNodeBean.selectedActivityResponse != null}"/>
                <p:commandButton value="保存"
                                 icon="fa fa-save"
                                 process="@this" actionListener="#{workflowNodeBean.onSave}"
                                 update="@form"
                                 oncomplete="PF('workflowNodeWidgetVar').hide()"/>
            </f:facet>
        </p:toolbar>
    </div>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12">
            <p:dataTable id="formNodeDataTable"
                         style="width: 100%"
                         var="activityResponse"
                         value="#{workflowNodeBean.activityResponses}"
                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                         reflow="true"
                         resizableColumns="true"
                         selectionMode="single"
                         selection="#{workflowNodeBean.selectedActivityResponse}"
                         rowKey="#{activityResponse.id}">

                <p:ajax event="rowSelect" listener="#{workflowNodeBean.onRowSelect}"
                        update=":workflowDefinitionListForm:workflowNodeToolBar"/>

                <p:column headerText="节点编码">
                    <h:outputText value="#{activityResponse.activityId}"/>
                </p:column>
                <p:column headerText="节点名称">
                    <h:outputText value="#{activityResponse.activityName}"/>
                </p:column>

                <p:column headerText="用户">
                    <h:outputText value="#{activityResponse.userAssigneeDisaply}"/>
                </p:column>
                <p:column headerText="角色">
                    <h:outputText value="#{activityResponse.roleAssigneeDisaply}"/>
                </p:column>

                <p:column headerText="执行者变量">
                    <h:outputText value="#{activityResponse.assigneeVariable}"/>
                </p:column>

                <p:column headerText="表单地址">
                    <h:outputText value="#{activityResponse.formUrl}"/>
                </p:column>
            </p:dataTable>
        </div>
    </div>
</p:dialog>

<p:dialog id="workflowNodeUserDialog" widgetVar="workflowNodeUserWidgetVar" modal="true" header="选择用户"
          resizable="false" width="1200" height="600">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="查询" icon="fa fa-search"
                             update=":workflowDefinitionListForm:workflowNodeUserDataTable"/>
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitUser}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeUserWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <div class="ui-g-12"><h3><b>查询条件</b></h3></div>
            <p:panelGrid columns="4" layout="grid"
                         columnClasses="ui-grid-col-2,ui-grid-col-3,ui-grid-col-2,ui-grid-col-3"
                         styleClass="ui-panelgrid-blank"
                         style="border:0px none; background-color:transparent;">

                <p:outputLabel value="姓名"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.name}"/>

                <p:outputLabel value="用户名"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.account}"/>

                <p:outputLabel value="邮箱"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.email}"/>

                <p:outputLabel value="联系电话"/>
                <p:inputText value="#{workflowNodeBean.systemUserSearchRequest.phone}"/>

                <p:outputLabel value="是否启用"/>
                <p:selectOneMenu value="#{workflowNodeBean.systemUserSearchRequest.enable}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                    <f:selectItem itemLabel="是" itemValue="true"/>
                    <f:selectItem itemLabel="否" itemValue="false"/>
                </p:selectOneMenu>

            </p:panelGrid>
            <div class="ui-g-12"><h3><b>用户列表</b></h3></div>
            <p:dataTable
                    id="workflowNodeUserDataTable"
                    style="width: 100%"
                    var="user"
                    value="#{workflowNodeBean.systemUserLazyDataModel}"
                    rows="#{constants:get('ROWS')}"
                    lazy="true"
                    paginator="true"
                    paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                    rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                    emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                    reflow="true"
                    scrollable="true"
                    scrollWidth="97%"
                    resizableColumns="true">
                <p:column headerText="操作">
                    <p:commandButton value="选择" icon="fa fa-retweet"
                                     actionListener="#{workflowNodeBean.onSelectUser(user.account)}"
                                     update="workflowNodeUserDataTable" process="@this"
                                     rendered="${!workflowNodeBean.isAssignedUser(user.account)}"/>
                    <p:commandButton value="取消" icon="fa fa-random"
                                     actionListener="#{workflowNodeBean.onUnselectUser(user.account)}"
                                     update="workflowNodeUserDataTable" process="@this"
                                     rendered="${workflowNodeBean.isAssignedUser(user.account)}"/>
                </p:column>
                <p:column headerText="姓名">
                    <h:outputText value="#{user.name}"/>
                </p:column>
                <p:column headerText="用户名">
                    <h:outputText value="#{user.account}"/>
                </p:column>
                <p:column headerText="邮箱">
                    <h:outputText value="#{user.email}"/>
                </p:column>
                <p:column headerText="联系电话">
                    <h:outputText value="#{user.phone}"/>
                </p:column>
                <p:column headerText="合作机构">
                    <h:outputText value="#{user.partnerName}"/>
                </p:column>
                <p:column headerText="是否启用">
                    <h:outputText value="#{user.enable ? '是' : '否'}"/>
                </p:column>
            </p:dataTable>
        </div>
    </div>
</p:dialog>


<p:dialog id="workflowNodeRoleDialog" widgetVar="workflowNodeRoleWidgetVar" modal="true" header="选择角色"
          resizable="false" width="1200" height="600">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="查询" icon="fa fa-search"
                             update=":workflowDefinitionListForm:workflowNodeRoleDataTable"/>
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitRole}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeRoleWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <div class="ui-g-12"><h3><b>查询条件</b></h3></div>
            <p:panelGrid columns="4" layout="grid"
                         columnClasses="ui-grid-col-2,ui-grid-col-3,ui-grid-col-2,ui-grid-col-3"
                         styleClass="ui-panelgrid-blank"
                         style="border:0px none; background-color:transparent;">

                <p:outputLabel value="角色编码"/>
                <p:inputText value="#{workflowNodeBean.roleSearchRequest.code}"/>

                <p:outputLabel value="角色名称"/>
                <p:inputText value="#{workflowNodeBean.roleSearchRequest.name}"/>


                <p:outputLabel value="是否启用"/>
                <p:selectOneMenu value="#{workflowNodeBean.roleSearchRequest.enable}">
                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                    <f:selectItem itemLabel="是" itemValue="true"/>
                    <f:selectItem itemLabel="否" itemValue="false"/>
                </p:selectOneMenu>

            </p:panelGrid>
            <div class="ui-g-12"><h3><b>用户列表</b></h3></div>
            <p:dataTable
                    id="workflowNodeRoleDataTable"
                    style="width: 100%"
                    var="role"
                    value="#{workflowNodeBean.roleLazyDataModel}"
                    rows="#{constants:get('ROWS')}"
                    lazy="true"
                    paginator="true"
                    paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                    rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                    emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                    reflow="true"
                    scrollable="true"
                    scrollWidth="97%"
                    resizableColumns="true">
                <p:column headerText="操作">
                    <p:commandButton value="选择" icon="fa fa-retweet"
                                     actionListener="#{workflowNodeBean.onSelectRole(role.code)}"
                                     update="workflowNodeRoleDataTable" process="@this"
                                     rendered="${!workflowNodeBean.isAssignedRole(role.code)}"/>
                    <p:commandButton value="取消" icon="fa fa-random"
                                     actionListener="#{workflowNodeBean.onUnselectRole(role.code)}"
                                     update="workflowNodeRoleDataTable" process="@this"
                                     rendered="${workflowNodeBean.isAssignedRole(role.code)}"/>
                </p:column>
                <p:column headerText="角色编码">
                    <h:outputText value="#{role.code}"/>
                </p:column>
                <p:column headerText="角色名称">
                    <h:outputText value="#{role.name}"/>
                </p:column>
                <p:column headerText="是否启用">
                    <h:outputText value="#{role.enable ? '是' : '否'}"/>
                </p:column>
            </p:dataTable>
        </div>
    </div>
</p:dialog>


<p:dialog id="workflowNodeVariablesDialog" widgetVar="workflowNodeVariablesWidgetVar" modal="true" header="执行者变量"
          resizable="false" width="300" height="200">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitVariables}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeVariablesWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <p:inputText value="#{workflowNodeBean.assigneeVariable}"/>
        </div>
    </div>
</p:dialog>

<p:dialog id="workflowNodeFormDialog" widgetVar="workflowNodeFormWidgetVar" modal="true" header="表单地址"
          resizable="false" width="600" height="200">
    <p:toolbar>
        <f:facet name="right">
            <p:commandButton value="提交" icon="fa fa-check" actionListener="#{workflowNodeBean.onSubmitFormUrl}"
                             update="formNodeDataTable" oncomplete="PF('workflowNodeFormWidgetVar').hide()"/>
        </f:facet>
    </p:toolbar>
    <div class="ui-g ui-fluid">
        <div class="ui-g-12 card">
            <p:inputText value="#{workflowNodeBean.formUrl}"/>
        </div>
    </div>
</p:dialog>

<p:dialog id="workflowScriptTaskDialog" widgetVar="workflowScriptTaskWidgetVar" modal="true" header="脚本任务管理"
          resizable="false" width="1200" height="600">
    <div class="clearfix"
         style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
        <p:toolbar>
            <f:facet name="right">
                <p:commandButton icon="fa fa-check" value="提交" actionListener="#{workflowNodeBean.onSubmitScriptTask}"/>
            </f:facet>
        </p:toolbar>
    </div>
    <p:tabView id="scriptTaskTabView" scrollable="true">
        <p:tab title="前置任务">
            <div class="ui-g ui-fluid">
                <div class="ui-g-12">
                    <p:inputTextarea rows="1000"
                                     value="#{workflowNodeBean.preScriptTaskContent}"/>
                </div>
            </div>
        </p:tab>
        <p:tab title="后置任务">
            <div class="ui-g ui-fluid">
                <div class="ui-g-12">
                    <p:inputTextarea rows="1000"
                                     value="#{workflowNodeBean.postScriptTaskContent}"/>
                </div>
            </div>
        </p:tab>
        <p:tab title="转办任务">
            <div class="ui-g ui-fluid">
                <div class="ui-g-12">
                    <p:inputTextarea rows="1000"
                                     value="#{workflowNodeBean.transScriptTaskContent}"/>
                </div>
            </div>
        </p:tab>
    </p:tabView>
</p:dialog>
</html>
